#pragma once
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string>

class InetAddr
{
public:
    InetAddr(sockaddr_in& addr)
    :_addr(addr)
    {
        _ip = inet_ntoa(addr.sin_addr);
        _port = ntohs(addr.sin_port);
    }

    std::string GetDebug()
    {
        std::string tmp = _ip;
        tmp += ':';
        tmp += std::to_string(_port);
        return tmp;
    }

    bool operator==(const InetAddr& addr)
    {
        return _ip == addr._ip && _port == addr._port;
    }
public:
    std::string _ip;
    uint16_t _port;
    sockaddr_in _addr;
};